﻿// offsetof宏的实现.
//

#include<stdio.h>
#include<stddef.h>
#define OFFSETOF(StructName,MemName) (int)&((StructName*)0)->MemName 
struct s
{
	char a;
	int b;
	double c;
};
int main()
{
	printf("%d\n", offsetof(struct s, a));
	printf("%d\n", offsetof(struct s, b));
	printf("%d\n", offsetof(struct s, c));
	printf("%d\n", OFFSETOF(struct s, a));
	printf("%d\n", OFFSETOF(struct s, b));
	printf("%d\n", OFFSETOF(struct s, c));
	return 0;
}